package Offer2019;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ThreadDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        FutureTask<Integer> futureTask = new FutureTask<>(new Data());

        new Thread(futureTask).start();
        //获取call方法的返回值
        System.out.println(futureTask.get());
    }
}


class Data implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        System.out.println("Callable创建线程");
        return 1024;
    }
}


